package summary.exception;

import java.io.File;

/**
 * @AUTHOR LYF
 * @DATE 2022/3/7
 * @VERSION 1.0
 * @DESC
 */
public class ExceptionDemo {
    // Throwable下的子类

    // Error类:OOM,StackOverFlowError -JVM 处理分析- 程序本身无法检查

    // Exception: unchecked(不受检，编译器不查类,空指针等) check fileCan not find

    static void test(){
        File file = new File("C://Desktop//hello.txt");
        if(file.exists())
        {
            System.out.println("存在");
        }else
        {
            System.out.println("不存在");
        }
        //Class.forName("hello") 该方法抛异常，使用则也需抛异常
    }

    static void test1() throws Exception{
        int i=1/0;
    }
    static void test2(){
        try {
            int i=1/0;
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    static void test3(int i) throws Exception {
        if(i==0)
        throw new Exception("hello0");
        else if(i==1)
        throw new Exception("hello1");
    }

    public static void main(String[] args) throws Exception {
        //test();
        //test1();
        test3(1);
    }
}
